package javolution.context;

import javolution.Javolution;
import javolution.lang.Configurable;
import javolution.util.StandardLog;

/* loaded from: classes2.dex */
public abstract class LogContext extends Context {
    private static volatile LogContext _Default = new StandardLog();
    public static final Class<? extends LogContext> STANDARD = _Default.getClass();
    public static final Class<? extends LogContext> NULL = new NullLog().getClass();
    public static final Class<? extends LogContext> SYSTEM_OUT = new SystemOut().getClass();
    public static final Class<? extends LogContext> CONSOLE = new ConsoleLog().getClass();
    public static final Configurable<Class<? extends LogContext>> DEFAULT = new Configurable(STANDARD) { // from class: javolution.context.LogContext.1
        @Override // javolution.lang.Configurable
        protected void notifyChange() {
            LogContext unused = LogContext._Default = (LogContext) ObjectFactory.getInstance((Class) get()).object();
        }
    };

    /* loaded from: classes2.dex */
    private static class ConsoleLog extends SystemOut {
        private ConsoleLog() {
            super();
        }
    }

    /* loaded from: classes2.dex */
    private static final class NullLog extends SystemOut {
        private NullLog() {
            super();
        }

        @Override // javolution.context.LogContext.SystemOut, javolution.context.LogContext
        public boolean isErrorLogged() {
            return false;
        }

        @Override // javolution.context.LogContext.SystemOut, javolution.context.LogContext
        public boolean isInfoLogged() {
            return false;
        }

        @Override // javolution.context.LogContext.SystemOut, javolution.context.LogContext
        public boolean isWarningLogged() {
            return false;
        }

        @Override // javolution.context.LogContext.SystemOut, javolution.context.LogContext
        public void logError(Throwable th, CharSequence charSequence) {
        }

        @Override // javolution.context.LogContext.SystemOut, javolution.context.LogContext
        public void logInfo(CharSequence charSequence) {
        }

        @Override // javolution.context.LogContext.SystemOut, javolution.context.LogContext
        public void logWarning(CharSequence charSequence) {
        }
    }

    /* loaded from: classes2.dex */
    private static class SystemOut extends LogContext {
        private SystemOut() {
        }

        @Override // javolution.context.LogContext
        public boolean isErrorLogged() {
            return true;
        }

        @Override // javolution.context.LogContext
        public boolean isInfoLogged() {
            return true;
        }

        @Override // javolution.context.LogContext
        public boolean isWarningLogged() {
            return true;
        }

        @Override // javolution.context.LogContext
        public void logError(Throwable th, CharSequence charSequence) {
            System.out.print("[error] ");
            if (th != null) {
                System.out.print(th.getClass().getName());
                System.out.print(" - ");
            }
            System.out.println(charSequence != null ? charSequence.toString() : th != null ? th.getMessage() : "");
            if (th != null) {
                th.printStackTrace();
            }
        }

        @Override // javolution.context.LogContext
        public void logInfo(CharSequence charSequence) {
            System.out.print("[info] ");
            System.out.println(charSequence);
        }

        @Override // javolution.context.LogContext
        public void logWarning(CharSequence charSequence) {
            System.out.print("[warning] ");
            System.out.println(charSequence);
        }
    }

    static {
        ObjectFactory.setInstance(new ObjectFactory() { // from class: javolution.context.LogContext.2
            /* JADX INFO: Access modifiers changed from: protected */
            @Override // javolution.context.ObjectFactory
            public Object create() {
                return new ConsoleLog();
            }
        }, CONSOLE);
        ObjectFactory.setInstance(new ObjectFactory() { // from class: javolution.context.LogContext.3
            /* JADX INFO: Access modifiers changed from: protected */
            @Override // javolution.context.ObjectFactory
            public Object create() {
                return new NullLog();
            }
        }, NULL);
        ObjectFactory.setInstance(new ObjectFactory() { // from class: javolution.context.LogContext.4
            /* JADX INFO: Access modifiers changed from: protected */
            @Override // javolution.context.ObjectFactory
            public Object create() {
                return new SystemOut();
            }
        }, SYSTEM_OUT);
    }

    public static void error(CharSequence charSequence) {
        getCurrent().logError((Throwable) null, charSequence);
    }

    public static final void error(String str) {
        getCurrent().logError((Throwable) null, str);
    }

    public static void error(Throwable th) {
        getCurrent().logError(th, (CharSequence) null);
    }

    public static void error(Throwable th, CharSequence charSequence) {
        getCurrent().logError(th, charSequence);
    }

    public static void error(Throwable th, String str) {
        getCurrent().logError(th, str);
    }

    public static LogContext getCurrent() {
        for (Context current = Context.getCurrent(); current != null; current = current.getOuter()) {
            if (current instanceof LogContext) {
                return (LogContext) current;
            }
        }
        return _Default;
    }

    public static LogContext getDefault() {
        return _Default;
    }

    public static void info(CharSequence charSequence) {
        getCurrent().logInfo(charSequence);
    }

    public static void info(String str) {
        getCurrent().logInfo(str);
    }

    public static void warning(CharSequence charSequence) {
        getCurrent().logWarning(charSequence);
    }

    public static void warning(String str) {
        getCurrent().logWarning(str);
    }

    @Override // javolution.context.Context
    protected void enterAction() {
    }

    @Override // javolution.context.Context
    protected void exitAction() {
    }

    public abstract boolean isErrorLogged();

    public abstract boolean isInfoLogged();

    public abstract boolean isWarningLogged();

    public abstract void logError(Throwable th, CharSequence charSequence);

    public final void logError(Throwable th, String str) {
        logError(th, Javolution.j2meToCharSeq(str));
    }

    public abstract void logInfo(CharSequence charSequence);

    public final void logInfo(String str) {
        logInfo(Javolution.j2meToCharSeq(str));
    }

    public abstract void logWarning(CharSequence charSequence);

    public final void logWarning(String str) {
        logWarning(Javolution.j2meToCharSeq(str));
    }
}
